package com.shujing.mapper;

import com.shujing.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


/**
 * @author 陈书憬
 * @version 1.0
 * 2024/4/8
 */
@Mapper
public interface UserMapper {

    /**
     * 查询该名字是否存在
     *
     * @param username
     * @return
     */
    @Select("select * from user where username = #{username}")
    User selectByName(String username);

    /**
     * 插入数据 用户名和密码
     *
     * @param username
     * @param password
     */
    @Insert("insert into user (username, password,create_time,update_time) values (#{username},#{password},now(),now())")
    void insertUser(String username, String password);

    /**
     * 更新用户基本信息
     * @param user
     */
    void updateUserInfo(User user);

    /**
     * 根据id查找用户信息
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User list(Integer userId);

}
